package pat;

import java.util.Scanner;

public class B1016 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        String stra = input.next();
        char da = input.next().charAt(0);
        String strb = input.next();
        char db = input.next().charAt(0);

        String pa = "";
        String pb = "";

        for (int i = 0; i < stra.length(); i++) {
            if (da == (stra.charAt(i))) {
                pa += da;
            }
        }
        if (pa.equals("")) {
            pa = "0";
        }

        for (int i = 0; i < strb.length(); i++) {
            if (db == (strb.charAt(i))) {
                pb += db;
            }
        }
        if (pb.equals("")) {
            pb = "0";
        }

        System.out.print(Integer.parseInt(pa) + Integer.parseInt(pb));

    }
}
